﻿@model Magicodes.WeiChat.Data.Models.Site.Site_NewsArticle
@{
    ViewBag.TwoTitle = "图文编辑";
}
@Html.Partial("_FormHead")
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <hr style="margin:2px 2px 10px 2px;" />

                    @using (Html.BeginForm())
                    {
                        @Html.AntiForgeryToken()

                        <div class="form-horizontal">
                            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                            <div class="form-group">
                                @Html.LabelFor(model => model.SiteArticleId, htmlAttributes: new { @class = "control-label col-sm-2" })
                                @Html.HiddenFor(model => model.SiteArticleId)
                                <div class="col-sm-10">
                                    <div class="input-group m-b">
                                        <span class="input-group-addon" id="btnChoiceArticle"><i class="fa fa-newspaper-o"></i></span>
                                        <input type="text" name="SiteArticleTitle" disabled="disabled" value="" class="form-control" />
                                    </div>

                                    @*<span class="help-block m-b-none">辅助性描述文字。</span>*@
                                    @Html.ValidationMessageFor(model => model.SiteArticleId, "", new { @class = "text-danger" })
                                </div>
                            </div>

                            <div class="form-group">
                                @Html.LabelFor(model => model.IsShowInText, htmlAttributes: new { @class = "control-label col-sm-2" })
                                <div class="col-sm-10">
                                    <div class="checkbox">
                                        @Html.EditorFor(model => model.IsShowInText, new { htmlAttributes = new { @class = "i-checks" } })
                                        @*<span class="help-block m-b-none">辅助性描述文字。</span>*@
                                        @Html.ValidationMessageFor(model => model.IsShowInText, "", new { @class = "text-danger" })
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                @Html.LabelFor(model => model.SiteImageId, htmlAttributes: new { @class = "control-label col-sm-2" })
                                @Html.HiddenFor(model => model.SiteImageId)
                                <div class="col-sm-10">
                                    <div class="input-group m-b">
                                        <span class="input-group-addon" id="btnChoicePic"><i class="fa fa-picture-o"></i></span>
                                        <input type="text" name="SiteImageName" disabled="disabled" value="" class = "form-control" />
                                    </div>

                                    @*<span class="help-block m-b-none">辅助性描述文字。</span>*@
                                    @Html.ValidationMessageFor(model => model.SiteImageId, "", new { @class = "text-danger" })
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-offset-2 col-sm-10">
                                    <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i>&nbsp;提交</button>
                                    <a href="@Url.Action("Index",new { newsId=Request.QueryString["newsId"]})" class="btn btn-primary"><i class="fa fa-mail-reply"></i>&nbsp;返回</a>
                                </div>
                            </div>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>
@section Styles {
    @*请自行移除没用到的样式*@
    @*复选框样式*@
    @Styles.Render("~/Content/plugins/iCheck/iCheckStyles")
    @*日期控件样式*@
    @Styles.Render("~/plugins/dataPickerStyles")
}
@section Scripts {
    @Scripts.Render("~/plugins/iCheck")
    <script>
        $('input[type=checkbox]').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green'
        });
    </script>
    <script>
        $(function () {
            $('#btnChoicePic').on('click', function () {
                mwc.window.show('选择图片', '@Url.Action("Index", "Site_Resources",new { resourceType= (int)Magicodes.WeiChat.Data.Models.Site.SiteResourceTypes.Gallery, lightLayout =1})')
            });
            $('#btnChoiceArticle').on('click', function () {
                mwc.window.show('选择文章', '@Url.Action("Index", "Site_Article", new { resourceType= (int)Magicodes.WeiChat.Data.Models.Site.SiteResourceTypes.Article, lightLayout =1})')
            });
        });
        function choice(data, type) {
            if (type == "Article") {
                $('input[name=SiteArticleId]').val(data.Id);
                $('input[name=SiteArticleTitle]').val(data.Name);
            } else {
                $('input[name=SiteImageId]').val(data.Id);
                $('input[name=SiteImageName]').val(data.Name);
            }
        }
    </script>
}
